<!DOCTYPE html>
<html lang="ch">
<head>
    <meta charset="UTF-8">
    <title>表格导入注册</title>
    <style>
        /**{*/
            /*padding: 0;*/
            /*margin: 0;*/
        /*}*/
        /*form{*/


        /*}*/
        .formbody{
            margin: 0 auto;
            padding-left:5%;
            padding-right: 5%;
            /*border: red solid 1px;*/
        }
        .form-group .tip{
            text-align: right;
            color: red;
            margin-right: 20px;
            margin-top: 10px;
        }
        a:hover{background-color: #5CB85C;}
        /*body {*/
            /*background-color: red;*/
        /*}*/

        .allcontainer  {

            padding-left:5%;
            padding-right: 5%;
            margin:0 auto;
            margin-top: 4%;
            border:2px solid darkslategray;
            padding-top: 60px;
            padding-bottom: 100px;
            border-radius:30px;

        }
    </style>
    <script src="/sybida/common/js/locahostadress.js" charset="utf-8"></script>
    <script src="/sybida/publicTool/js/downloadfile.js" charset="utf-8"></script>
    <link rel="stylesheet" href="/sybida/bs/bootstrap.min.css">
    <link rel="stylesheet" href="/sybida/layui/css/layui.css"  media="all">

</head>
<body>

<div class="container allcontainer" style="width: 40%;">
    <div class="header" style="text-align: center;margin-bottom: 20px;">
        <span style="font-size: 26px; font-weight: bold;">批量添加学生信息</span>
    </div>
    <div class="formbody">
    <form enctype="multipart/form-data">
    <div class="form-group">
        <label for="classCreate">创建新班</label>
        <input type="text" name="classCreate" class="form-control" id="classCreate" >
        <p class="tip"></p>
    </div>
        <div class="form-group">
            <label for="insetManagerId">班主任是您自己</label>
            <input type="text" name="insetManager" class="form-control" id="insetManagerId" readonly="readonly">
            <p class="tip"></p>
        </div>
        <div class="form-group">
            <label for="selectStudy">选择学习方向</label>
            <select class="form-control" id="selectStudy" name="selectStudy">
            </select>
        </div>
        <div class="form-group">
            <label for="selectTeacher">选择授课老师</label>
            <select class="form-control" id="selectTeacher" name="selectTeacher">
            </select>
        </div>
        <div class="form-group">
            <input type="button" id="templet" class="btn btn-success" value="请下载模板"style="width: 100%">
        </div>

    <div class="form-group">
            <input type="file" id="reportXML" accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" name="file">
    </div>
    <div class="form-group"><input id="sureregister" type="button" onclick="submitXML()" class="btn btn-success" value="确定" style="width: 100%"></div>
    </form>
    </div>
</div>

    <script src="/sybida/layui/layui.js"></script>
    <!--<script src="/sybida/bs/bootstrap.min.js"></script>-->
    <script src="/sybida/jquery/jquery-3.3.1.min.js"></script>
    <script src="/sybida/common/js/register.js"></script>
<script>

    var userid=getCookie("userid")
    $.getJSON({
        url:url+"/register/getCookValue?userid="+userid,
        beforeSend: function(request) {
            request.setRequestHeader("token", userid);
        },
        success:function (data) {
            if(data== -1000){
                location.href=logindexurl
            }else {
                $("#insetManagerId"). attr("value",data.data)
            }
    }})



</script>
<script>
    var layer
    layui.use('layer', function(){
        layer = layui.layer;
    });
    window.onload=function() {
        var createClass = document.getElementById("classCreate")
        var classLab = document.getElementsByClassName("tip")[0];
        createClass.onfocus = function () {
            classLab.style.display = "inline-block";
            classLab.innerHTML = '<i class="warn"></i> 请输入1-20个字符';
        }
        createClass.onblur = function () {
            if (this.value== "") {
                classLab.innerHTML = '<i class="cuo"></i> 不能为空';
            } else if (this.value.length < 1 || this.value.length > 20) {
                classLab.innerHTML = '<i class="cuo"></i> 长度应为1-20个字符';
            } else {
                classLab.innerHTML = "";
            }
            var className=$("#classCreate").val()
            $.getJSON({
                url:url+"/register/selectClassName?className="+className,
                beforeSend: function(request) {
                    request.setRequestHeader("token", userid);
                },
                success:function (data) {
                    if(data== -1000){
                        location.href=logindexurl
                    }else {

                        if (data.code == 1) {

                        } else {
                            classLab.innerHTML = '<i class="warn"></i> 班级名重复，换一个试试';
                        }
                    }
            }})
        }
        }

</script>


</body>
</html>